package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateCheckAccountByPageDTO;
import com.itlong.cloud.POJO.VO.operate.OperateCheckAccountGetPageVO;
import com.itlong.cloud.operate.service.ICheckAccountService;
import com.itlong.cloud.paymenthub.ICheckAccountServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 * 运营-财务展示对账服务实现类.
 * </desc>
 *
 * @createDate 2018/9/19
 */
@RestController
public class CheckAccountServiceResource implements ICheckAccountServiceClient{
    @Autowired
    ICheckAccountService iCheckAccountService;

    /**
     * <desc>
     *      根据条件分页查询自动出账的出入列表
     * <desc/>
     * @param   checkAccountByPageDTO 查询条件
     * @return page
     * @author Juguang.S
     * @createDate 2018/9/19
     */
    @Override
    @PostMapping(path= "/checkAccount/autoCheckDiffInfo")
    public Page<OperateCheckAccountGetPageVO> getCheckDiffInfoByPage(@RequestBody OperateCheckAccountByPageDTO checkAccountByPageDTO)  throws Exception {
        return iCheckAccountService.getCheckDiffInfoByPage(checkAccountByPageDTO);
    }

    /**
     * <desc>
     *      根据ID查询其备注和订单状态
     * <desc/>
     *
     * @param orderDiffId
     * @return
     * @author Juguang.S
     * @createDate 2018-09-19
     */
    @Override
    @PostMapping(path= "/checkAccount/getCheckInfo")
    public Map<String,Object> getCheckInfo(@RequestParam("orderDiffId") String orderDiffId) {
        return iCheckAccountService.getCheckInfo(orderDiffId);
    }

    /**
     * <desc>
     *      根据ID修改其备注和订单状态
     * <desc/>
     *
     * @param orderDiffId id
     * @param remark 备注
     * @param diffOrderStatus 订单状态
     * @return
     * @author Juguang.S
     * @createDate 2018-09-19
     */
    @Override
    @PostMapping(path= "/checkAccount/updateStatus")
    public void updateStatus(@RequestParam("orderDiffId") String orderDiffId,
                             @RequestParam("diffOrderStatus") String diffOrderStatus,
                             @RequestParam("remark") String remark,
                             @RequestParam("myUserName") String myUserName) {
        iCheckAccountService.updateStatus(orderDiffId,diffOrderStatus,remark,myUserName);
    }

    /**
     * <desc>
     *      根据条件查询出所有出入信息
     * <desc/>
     *
     * @param checkAccountByPageDTO 条件
     * @return
     * @author Juguang.S
     * @createDate 2018-09-19
     */
    @Override
    @PostMapping(path= "/checkAccount/exportDiffInfo")
    public List<OperateCheckAccountGetPageVO> getDiffInfo(@RequestBody OperateCheckAccountByPageDTO checkAccountByPageDTO) throws Exception {
        return iCheckAccountService.getDiffInfo(checkAccountByPageDTO);
    }


}